module(..., package.seeall) -- 使得文件中的函数在何处都可调用

require "misc"
require "mqtt"
require "nvm"

-- 初始化nvm获取配置参数
nvm.init("config.lua", true)

--参数初始化
local slen, orgId, typeId, version, clientNo = string.len, nvm.get("OrgId"), nvm.get("TypeId"),nvm.get("Version"),nvm.get("ClientNo")

function checkDeviceOnline(mqttClient)
    local online = "{" .. "clientNo:'" .. clientNo .. ",version:'" ..
        version .. "',msg:'1'" .. "}"
    online = crypto.aes_encrypt("ECB", "PKCS5", online,
        "keson-123abcdefg")
    online = crypto.base64_encode(online, slen(online))
    mqttClient:publish("online", online, 0)
end
